<?php
echo $this->Html->script('jquery.ui.core.min');
echo $this->Html->script('jquery.validate.min');
echo $this->Html->script('jquery.ui.datepicker.min');
echo $this->Html->css('jquery-ui');
?>
<script type="text/javascript">
    $(document).ready(function(){
        $("form").validate({
            errorClass: "jqueryError",
            errorElement: 'label',
            debug: false,
            submitHandler: function(form) {
                $(':submit', form).attr('disabled', 'disabled').addClass('inactive');
                form.submit();
            }
        });
    });

    $(function(){
        var dates = $('#ActivityDuedate, #ActivityNextfollowupdate').datepicker({
            defaultDate: new Date(),
            changeMonth: true,
            changeYear: true,
            dateFormat: 'dd-mm-yy',
            showOn: 'button',
            buttonImage: '<?php echo APP_URL; ?>img/calendar.png',
            buttonImageOnly: true,
            onSelect: function(selectedDate) {
                var option = this.id == "ActivityDuedate" ? "minDate" : "maxDate";
                var instance = $(this).data("datepicker");
                var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
                dates.not(this).datepicker("option", option, date);
            }
        });
    })
</script>
<div class="activities form">
    <?php echo $this->Form->create('Useractivity'); ?>
    <fieldset>
        <legend><?php __('Edit User Activity'); ?></legend>
        <?php
        echo $this->Form->input('id');
        echo $this->Form->input('potential_id', array(
            'type' => 'hidden'
        ));

        echo "<h3>" . $this->Form->label('username', $this->data['Potential']['User']['firstname']." ".$this->data['Potential']['User']['lastname'], null) . "</h3>";

        echo $this->Form->input('activitytype_id', array(
            'label' => 'Activity Type',
            'class' => 'required',
            'between' => $this->Html->tag('span', '(Please choose an activity type from the list below)', array('class' => 'description'))
        ));

        echo $this->Form->input('subject', array(
            'label' => 'Subject',
            'class' => 'required',
            'between' => $this->Html->tag('span', '(Enter a subject for the activity)', array('class' => 'description'))
        ));

        echo $this->Form->input('description', array(
            'label' => 'Description',
            'type' => 'textarea',
            'between' => $this->Html->tag('span', '(Please add some description)', array('class' => 'description'))
        ));

        echo $this->Form->input('duedate', array(
            'label' => 'Due Date',
            'type' => 'text',
            'value' => $this->Time->format('d-m-Y',$this->data['Activity']['duedate'])
        ));

        echo $this->Form->input('nextfollowupdate', array(
            'label' => 'Next Followup Date',
            'type' => 'text',
            'value' => $this->Time->format('d-m-Y',$this->data['Activity']['nextfollowupdate'])
        ));

        echo $this->Form->input('employee_id', array(
            'type' => 'hidden',
            'value' => $this->Session->read('Auth.Employee.id')
        ));

        echo $this->Form->input('assignedtoemployee_id', array(
            'label' => 'Assigned To Employee'
        ));

        echo $this->Form->input('donedate', array(
            'label' => 'Done Date',
            'type' => 'hidden',
            'value' => date('Y-m-d H:i:s')
        ));

        echo $this->Form->input('status');
        ?>
    </fieldset>
    <?php echo $this->Form->end(__('Submit', true)); ?>
    </div>